package com.rd.util;

import com.rd.common.CommonResult;
import com.rd.common.constant.ApiConstant;

/**
 * 生成CommonResult对象的帮助类
 */
public class ResultUtil {

    public static CommonResult buildSuccess(){
        return CommonResult.builder().message(ApiConstant.SUCCESS_MESSAGE).code(200).build();
    }

    public static CommonResult buildSuccess(Object data){
        return CommonResult.builder().message(ApiConstant.SUCCESS_MESSAGE).data(data).code(200).build();
    }

    public static CommonResult buildSuccess(String message, Object data){
        return CommonResult.builder().message(message).data(data).code(200).build();
    }

    public static CommonResult buildError(Integer code,String message){
        return CommonResult.builder().message(message).data(null).code(code).build();
    }
    public static CommonResult buildError(String message){
        return CommonResult.builder().message(message).data(null).code(ApiConstant.ERROR_CODE).build();
    }
    public static CommonResult buildError(){
        return CommonResult.builder().message(ApiConstant.ERROR_MESSAGE).data(null).code(ApiConstant.ERROR_CODE).build();
    }
}

